package springboot.example.springboot.service;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import springboot.example.springboot.dao.PhotoDao;
import springboot.example.springboot.entity.Photo;
import springboot.example.springboot.tools.MyExecption;

import javax.annotation.Resource;

@Service
public class PhotoService {
    @Resource
    private PhotoDao photoDao;

    public void save(Photo photo) throws MyExecption{

        if(StringUtils.isBlank(photo.getImgDescribe())){
            throw new MyExecption("图片描述不能为空");
        }
        if(StringUtils.isBlank(photo.getImgUrl())){
            throw new MyExecption("图片地址不能为空");
        }

        photoDao.save(photo);
    }
}
